package com.cf.studiomanage.mapper;

import com.cf.studiomanage.entity.Announcement;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AnnouncementMapper {

    @Insert("INSERT INTO announcement(title, content, created_by) VALUES(#{title}, #{content}, #{createdBy})")
    int publish(Announcement announcement);

    @Select("SELECT * FROM announcement ORDER BY created_at DESC")
    List<Announcement> getAll();

    @Select("SELECT * FROM announcement WHERE id = #{id}")
    Announcement getById(Long id);
}
